package com.yc.cloud.openai.portal.dao.impl;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.stereotype.Component;

import com.yc.cloud.openai.portal.dao.GPTChatClient;
import com.yc.cloud.openai.portal.dto.gpt.GPTCreateDatasetCollectionDataDto;
import com.yc.cloud.openai.portal.dto.gpt.GptDatasetCollectionCreateDto;
import com.yc.cloud.openai.portal.dto.gpt.GptDatasetCreateDto;
import com.yc.cloud.openai.portal.dto.gpt.GptDatasetUpdateDto;
import com.yc.cloud.openai.portal.dto.request.ChatCompletionsRequest;
import com.yc.cloud.openai.portal.dto.response.GPTChatResponseResult;

import reactor.core.publisher.Flux;

@Component("LINK_AI")
public class LinkAIClientImpl implements GPTChatClient {


    private final ChatClient chatClient;

    public LinkAIClientImpl(ChatClient.Builder chatClientBuilder) {
        this.chatClient = chatClientBuilder.build();
    }

//    @Override
//    public Flux<String> completionsByStream(ChatCompletionsRequest request) {
//        return chatClient.prompt()
//                .user(request.getMessage())
//                .stream()
//                .content().doOnComplete(() -> Flux.just("[DONE]"));
//    }

    @Override
    public Flux<String> completionsByStream(ChatCompletionsRequest request) {
        return chatClient.prompt()
                .user(request.getMessage())
                .stream()
                .content()
                .concatWith(Flux.just("[DONE]"));
    }

    @Override
    public String completions(ChatCompletionsRequest request) {
        return chatClient.prompt()
                .user(request.getMessage())
                .call()
                .content();
    }

    @Override
    public GPTChatResponseResult<GPTCreateDatasetCollectionDataDto>  createDatasetCollection(GptDatasetCollectionCreateDto request) {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'createDatasetCollection'");
    }

    @Override
    public GPTChatResponseResult<String>  createDataset(GptDatasetCreateDto request) {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'createDataset'");
    }

    @Override
    public GPTChatResponseResult deleteDataset(String datasetId) {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'deleteDataset'");
    }

    @Override
    public GPTChatResponseResult updateDataset(GptDatasetUpdateDto gptDatasetUpdateDto) {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'updateDataset'");
    }

    @Override
    public GPTChatResponseResult deleteDatasetCollection(String collectionId) {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'deleteDatasetCollection'");
    }
}
